package com.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class TestSingleThreadPool {

	public static void main(String[] args){
		ExecutorService singleExecutorService = Executors.newSingleThreadExecutor();
		Future mFeature = singleExecutorService.submit(new Runnable() {
			@Override
			public void run() {
				while (true){
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						return;
					}

					System.out.println("action");
				}
			}
		});

		new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					Thread.sleep(5000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				singleExecutorService.shutdownNow();
			}
		}).start();

	}
}
